#ifndef __dhs_Looper
#define __dhs_Looper

#include <mutex>
#include <condition_variable>
#include <queue>
#include <functional>
#include <memory>

struct Msg
{
std::function<void()> callback;
};


class Looper
{
private:
    /* data */
std::mutex mutex;
std::mutex queue_mutex;
std::condition_variable condition;
std::queue<Msg>  queue;

bool interrupt;
std::unique_lock<std::mutex> acquire_lock();

public:
    Looper(/* args */);

    Looper(const Looper&) =delete;
    Looper& operator=(const Looper &) = delete;

    ~Looper();
  
  void postmessage(Msg msg);
  void exit();
  
  void  run();
};





#endif